package com.javaear.generalmapper.configuration;

import com.javaear.generalmapper.plugin.GeneralSqlInjector;
import com.javaear.generalmapper.processor.TableNameAnnotationProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GeneralMapperBootstrapConfiguration {

    @Bean
    public TableNameAnnotationProcessor generalMapper() {
        return new TableNameAnnotationProcessor(generalSqlInjector());
    }

    @Bean
    public GeneralSqlInjector generalSqlInjector() {
        return new GeneralSqlInjector();
    }

    /*@Bean
    public MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean(SqlSessionFactoryBean sqlSessionFactoryBean) {
        MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
        BeanUtils.copyProperties(sqlSessionFactoryBean, mybatisSqlSessionFactoryBean);
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        //TODO 根据datasource driver 获取数据库类型
        //paginationInterceptor.setDialectType(sqlSessionFactoryBean.getDatabaseIdProvider().toString());
        paginationInterceptor.setDialectType("mysql");
        mybatisSqlSessionFactoryBean.setPlugins(new Interceptor[]{paginationInterceptor});
        return mybatisSqlSessionFactoryBean;
    }
*/
}
